{%include file="index.header.tpl.php"%}
{%include file="index.left.tpl.php"%}
  <!--主要内容开始-->
<div class="content-wrapper">
    <section class="content">
        <div class="row">
            <form action="" method="get">
            <section class="col-sm-3 connectedSortable" style="padding-right:0px;">
                <div class="box box-solid">
                    <div class="box-header with-border" id="boring">
                        <div class="form-group">
                            <select id="sem_id" name="semester_id" class="form-control" style="padding:0;">
                                <option>请选择学年学期</option>
                                {%foreach from=$semester_lists key=key item=value%}
                                <option value="{%$value.semester_id%}">{%$value.semester_name%}</option>
                                {%/foreach%}
                            </select>
                        </div>
                        <div class="form-group">
                            <select name="exam_id" id="number33" class="form-control" style="padding:0;">
                                <option>请先选择学期</option>
                            </select>
                        </div>
                    </div>
                </div>
                <div class="box box-solid">
                    <div class="box-header with-border">
                        <div class="form-group">
                            <select class="form-control" name="grade_id" id="grade_id">
                                <option value="">请选择年级</option>
                                {%foreach from=$grade_lists key=key item=value%}
                                <option value="{%$value.grade_id%}">{%$value.grade_name%}</option>
                                {%/foreach%}
                            </select>
                        </div>
                        <div class="form-group class" style="height:100px; overflow-y:scroll;" id="number3">

                        </div>

                    </div>
                </div><!--box box-solid-->

                <div class="box box-solid">
                    <div class="box-header with-border">
                        <label class="col-sm-2" style="padding:0">科目</label>
                        <div class="col-sm-9 form-group" style="height:100px; overflow-y:scroll; margin-bottom:30px;">
                            <label><input type="radio" name="subject_id" value="all"> 总分</label><br/>
                            {%foreach from=$subject_lists key=key item=value%}
                            <label><input type="radio" name="subject_id" value="{%$value.subject_id%}">{%$value.subject_name%}</label><br/>
                            {%/foreach%}
                        </div>
                        <div style="clear:both;">
                            <input type="hidden" name="a" value="score.goodbad">
                            <button type="submit" class="btn btn-primary btn-sm">确定查询</button>
                        </div>
                    </div>
                </div><!--box box-solid-->
            </section>
            </form>
            <!--左边结束-->
            <form action="" method="post">
                <section class="col-lg-9 connectedSortable">
                    <div class="box box-default box-solid">
                        <div class="box-header with-border">
                            <div class="form-group col-sm-3">
                                <label class="col-md-5 control-label" style="padding:0; font-weight:500;">
                                    绩优生：
                                </label>
                                <div class="input-group col-md-7 col-sm-7 col-xs-8">
                                    <input name="good" type="text" class="form-control">
                                </div>
                            </div>
                            <div class="form-group col-sm-3">
                                <label class="col-md-5 control-label" style="padding:0; font-weight:500;">
                                    绩差生：
                                </label>
                                <div class="input-group col-md-7 col-sm-7 col-xs-8">
                                    <input name="bad" type="text" class="form-control">
                                </div>
                            </div>
                            <input type="hidden" name="semester_id" value="{%$semester%}">
                            <input type="hidden" name="grade_id" value="{%$grade%}">
                            <input type="hidden" name="exam_id" value="{%$exam%}">
                            <input type="hidden" name="subject_id" value="{%$subject%}">
                            <input type="hidden" name="nian" value="{%$classes%}">
                            <button type="submit" class="btn btn-primary" style="color:#fff;">查 询</button>
                            <a href="" class="btn btn-warning btn-sm" style="float:right; color:#fff;">导 出</a>
                        </div>

                        <div class="box-body">
                            <h4 class="text-center">{%$semester_name%}{%$grade_name%}{%$exam_name%}{%$subject_name%}{%$limit%}</h4>
                            <table class="table table-bordered table-responsive"  id="mytable">
                                <thead>
                                <tr>
                                    <td>班级(座号)</td>
                                    <td>姓名</td>
                                    <td>本次排名</td>
                                    <td>上次排名</td>
                                    <td>本次分数</td>
                                    <td>上次分数</td>
                                </tr>
                                </thead>
                                {%foreach from=$score_lists item=value%}
                                <tr>
                                    <td>{%$value.classname%}({%$value.seat%})</td>
                                    <td>{%$value.student_name%}</td>
                                    <td>{%$value.rank%}</td>
                                    <td>{%$value.rank2%}</td>
                                    <td>{%$value.mysum%}</td>
                                    <td>{%$value.mysum2%}</td>
                                     </tr>
                                {%/foreach%}

                            </table>
                        </div><!--box-body -->

                    </div><!--box box-default box-solid-->
                </section>
            </form>
        </div><!--row-->
    </section>
</div>
  <!--主要内容结束-->
{%include file="index.footer.tpl.php"%}

<script type="text/javascript">
    $(document).ready(function () {
        $("#grade_id").change(function () {
            if ($(this).val() == "-1") {
                $("#industr").remove(); return;
            }
            else {
                var timestamp = new Date().getTime();
                $.ajax({
                    url:"index.php?a=student.gradelistjson",
                    type:"get",
                    data: "grade_id=" + $("#grade_id").find("option:selected").val() + "&timestamp=" + timestamp,
                    dataType:"json",
                    success:function(msg){
//                        <label><input type="checkbox" name="allChecked" id="allChecked" onclick="DoCheck()"> 全选 </label><br/>
//                            <label><input type="checkbox" name="nian[]"> 初一2班（文科班） </label><br/>
                        //实例2个字符串变量来拼接下拉列表
                        var industr = "";
                        //使用jquery解析json中的数据
                        $.each(msg, function (n, value) {
                            industr += ("<label><input type='checkbox' name='nian[]' value=\"" + value.class_id + "\">" + value.class_name);
                            industr += ("</label><br/>");
                        });
                        var top = "<label><input type='checkbox' name='allChecked' id='allChecked' onclick='DoCheck()'> 全选 </label><br/>"
                        $("#number3").html(top+industr);
                    }
                });

            }

        });

    });
</script>
<script type="text/javascript">
    $(document).ready(function () {
        $("#sem_id").change(function () {
            if ($(this).val() == "-1") {
                $("#industr2").remove(); return;
            }
            else {
                var timestamp = new Date().getTime();
                $.ajax({
                    url:"index.php?a=score.semjson",
                    type:"get",
                    data: "sem_id=" + $("#sem_id").find("option:selected").val() + "&timestamp=" + timestamp,
                    dataType:"json",
                    success:function(msg){

                        //实例2个字符串变量来拼接下拉列表
                        var industr = "";
                        //使用jquery解析json中的数据
                        $.each(msg, function (n, value) {
                            industr += ("<option value=\"" + value.exam_id + "\">" + value.exam_name);
                            industr += ("</option>");
                        });

                        $("#number33").html(industr);
                    }
                });

            }

        });

    });
</script>
<script>
    $(function(){
        $(".all").hide();
    })
    function grade_change()
    {
        $(".all").hide();
        var val = $("#number1").val();
        $("#"+val).show();
    }

</script>
<script>
    //checbox全选
    function DoCheck()
    {
        var ch=document.getElementsByName("nian[]");
        if(document.getElementsByName("allChecked")[0].checked==true)
        {
            for(var i=0;i<ch.length;i++)
            {
                ch[i].checked=true;
            }
        }else{
            for(var i=0;i<ch.length;i++)
            {
                ch[i].checked=false;
            }
        }
    }
</script>
